<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Ticket History</title>
<link href="UniversalStyleSheet.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
	margin-left: 1px;
	margin-top: 1px;
	margin-right: 1px;
	margin-bottom: 1px;
	}
.RedText {
	color:#990000
	}
.GreenText {
	color:#009900
	}
-->
</style></head>

<body>
<table width="210" border="0" cellspacing="0" cellpadding="0">
  <caption align="top" class="TableTitles">
    Ticket History
  </caption>
  <tr>
    <td width="20" height="20" background="Images/TableUpperLeft.png"></td>
    <td height="20" background="Images/TableUpperMiddle.png"></td>
    <td width="20" height="20" background="Images/TableUpperRight.png"></td>
  </tr>
  <tr>
    <td width="20" background="Images/TableMiddleLeft.png"></td>
    <td bgColor='#FFFFFF'>
	<table border="1" width="100%" bordercolor="#009900" >
	
		<% 'fill table with info
			if request.QueryString("Contract_ID")<>"" then
				dim db,rs
				set db=server.CreateObject("adodb.connection")
				set rs=server.CreateObject("adodb.recordset")
				FilePath=server.MapPath("/afterhours/access/backend/tickets.mdb")
				db.open"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filepath
				sql="select Ticket_ID, Status, Emergency, Appliance, Created_Time from Tickets where Contract_ID='" & request.QueryString("Contract_ID") & "'"
				
				rs.open sql,db,1,2
				if rs.eof then
					rcnt=0
					redim ra(0,0)
					ra(0,0)="(No Ticket History)"
					history="none"
					rs.close
					db.close
					set rs=nothing
					set db=nothing
				else
					ra=rs.getrows()'0=Ticket_ID, 1=Status, 2=Emergency, 3=Appliance, 4=Created_Time
					set rs=nothing
					db.close
					set db=nothing
					x=0
					history="some"
				end if
			else
				redim ra(0,0)
				ra(0,0)=""
				history="none"
			end if
			
			do until x>ubound(ra,2)
				%>
				<tr><td onMouseOver="this.bgColor='#d2ffd2'" onMouseOut="this.bgColor='#FFFFFF'" bordercolor="#FFFFFF" class="ListCell">
				<%
				if history="some" then
					response.Write("<a href='TicketWindow.asp?Ticket_ID=" & ra(0,x) & "' target='TicketFrame'>")
					response.Write(ra(0,x) & " &nbsp; &nbsp; " & ra(3,x) & "&nbsp; &nbsp; <br/>" & ra(4,x) & " <br/> ")
					if ra(2,x)="Yes" then 
						emergencystring="<span class='RedText'>Emergency</span>"
					else
						emergencystring="Non-Emergency"
					end if
						
					select case ra(1,x)
						case "Cancelled"
							statusstring="<span class='RedText'>Cancelled</span>"
						case "Open"
							statusstring="<span class='GreenText'>Open</span>"
						case else
							statusstring=ra(1,x)
					end select
						
					response.Write(statusstring & " &nbsp; &nbsp; " & emergencystring & " <br/> ")
					response.Write("<a>")
					if x<ubound(ra,2) then response.Write("</td></tr>")
				else
					response.Write(ra(0,0))
				end if
				x=x+1
			loop
						
	%>
	</td></tr>
	</table>				
	</td>
    <td width="20" background="Images/TableMiddleRight.png"></td>
  </tr>
  <tr>
    <td width="20" height="20" background="Images/TableLowerLeft.png"></td>
    <td height="20" background="Images/TableLowerMiddle.png"></td>
    <td width="20" height="20" background="Images/TableLowerRight.png"></td>
  </tr>
</table>
</body>
</html>
